Skip to content

fix(api): return 403 for authorization failures, reserve 401 for missing session - #41661

Closed
surjeetkumar8006 wants to merge 1 commit into
RocketChat:developfrom
surjeetkumar8006:fix/api-401-403-semantics-v5
Closed

fix(api): return 403 for authorization failures, reserve 401 for missing session#41661
surjeetkumar8006 wants to merge 1 commit into
RocketChat:developfrom
surjeetkumar8006:fix/api-401-403-semantics-v5

Conversation

@surjeetkumar8006

@surjeetkumar8006 surjeetkumar8006 commented Aug 2, 2026

Copy link
Copy Markdown

Proposal

Fixes REST API HTTP status code semantics for authentication vs authorization failures and aligns validation errorType naming consistency across the typed router, resolving #41589.

Endpoints

ApiClass, Router, permissionsMiddleware, rooms.getMembers, rooms.hide, rooms.bannedUsers, rooms.adminRooms

Notes

  • Reserve 401 status strictly for unauthenticated requests (!user / missing session).
  • Remap permission denials (error-unauthorized / error-not-authorized) to 403 (forbidden).
  • Align Router.ts body validation error type from invalid-params to error-invalid-params matching ajvQuery failure responses.
  • Clean up dead applyBreakingChanges branch in permissions.ts middleware and update rooms.ts response schemas to validateForbiddenErrorResponse.
  • Add changeset for patch release.

Task: #41589

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Authorization failures now consistently return 403 Forbidden; 401 Unauthorized is reserved for missing sessions.
    • Permission-denied responses are handled consistently across room, administrative, and LDAP endpoints.
    • API errors are now correctly identified across supported error formats.
  • Improvements

    • Request validation errors now consistently use error-invalid-params for invalid or missing query and body parameters.
    • Updated API migration guidance and validation coverage to reflect standardized error behavior.

@surjeetkumar8006
surjeetkumar8006 requested a review from a team as a code owner August 2, 2026 13:23
@dionisio-bot

dionisio-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 504dbca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/http-router Patch
@rocket.chat/core-services Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c1f8503d-e689-42d6-9451-b40fda5eaae8

📥 Commits

Reviewing files that changed from the base of the PR and between 85d3b43 and 504dbca.

📒 Files selected for processing (9)
  • .changeset/real-mails-count.md
  • apps/meteor/ee/server/api/ldap.ts
  • apps/meteor/server/api/ApiClass.ts
  • apps/meteor/server/api/v1/ldap.ts
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
  • docs/api-endpoint-migration.md
  • packages/http-router/src/Router.spec.ts
  • packages/http-router/src/Router.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/meteor/server/api/ApiClass.ts
  • docs/api-endpoint-migration.md
  • .changeset/real-mails-count.md
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
  • packages/http-router/src/Router.ts
  • packages/http-router/src/Router.spec.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/ee/server/api/ldap.ts
  • apps/meteor/server/api/v1/ldap.ts
🧠 Learnings (6)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/ee/server/api/ldap.ts
  • apps/meteor/server/api/v1/ldap.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/ee/server/api/ldap.ts
  • apps/meteor/server/api/v1/ldap.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/ee/server/api/ldap.ts
  • apps/meteor/server/api/v1/ldap.ts
📚 Learning: 2026-07-31T00:32:03.839Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 41635
File: apps/meteor/ee/server/api/roles.ts:101-111
Timestamp: 2026-07-31T00:32:03.839Z
Learning: In Rocket.Chat's typed EE REST API routes that use apps/meteor/ee/server/api/v1/middlewares/license.ts, account for unavailable route-level license modules returning HTTP 400 with { success: false, error, errorType: 'error-action-not-allowed' }, not HTTP 403. Declare the existing 400 bad-request response schema for these routes.

Applied to files:

  • apps/meteor/ee/server/api/ldap.ts
📚 Learning: 2026-07-31T02:44:35.111Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 41635
File: apps/meteor/ee/server/api/sessions.ts:114-138
Timestamp: 2026-07-31T02:44:35.111Z
Learning: In Rocket.Chat typed REST response schemas, accept the composition of a Typia-generated entity schema with an `allOf` branch requiring `success: true`: `allOf: [{ $ref: <entity schema> }, { properties: { success: { type: 'boolean', enum: [true] } }, required: ['success'] }]`. Do not flag this pattern when used for REST endpoints, provided TEST_MODE response validation passes, as demonstrated by the `IOAuthApps` and `IEmailInbox` endpoints.

Applied to files:

  • apps/meteor/ee/server/api/ldap.ts
  • apps/meteor/server/api/v1/ldap.ts
📚 Learning: 2026-07-29T23:45:21.859Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 41632
File: apps/meteor/server/api/v1/groups.ts:948-959
Timestamp: 2026-07-29T23:45:21.859Z
Learning: For API v1 routes under apps/meteor/server/api/v1, keep item-level response schemas strict by using `$ref`-based schemas for list and messages (and ensure they intentionally mirror the corresponding route contracts, as done in channels.ts). Only use “loose”/non-`$ref` item schemas when the underlying data source is inherently partial (e.g., uploads where `content` can be `null`, or queries like `findUsersOfRoom` with a fixed projection). Do not relax item schemas merely because the route supports an optional client `fields` projection—optional field selection alone is not a reason to change schema strictness.

Applied to files:

  • apps/meteor/server/api/v1/ldap.ts
🔇 Additional comments (2)
apps/meteor/ee/server/api/ldap.ts (1)

32-32: LGTM!

apps/meteor/server/api/v1/ldap.ts (1)

34-34: LGTM!

Also applies to: 68-68


Walkthrough

The API now distinguishes missing sessions from authorization failures by using HTTP 401 and 403 respectively. Room endpoints expose 403 responses for access failures. Body validation uses error-invalid-params, with tests and migration guidance updated.

Changes

API error response normalization

Layer / File(s) Summary
Authorization error classification
apps/meteor/server/api/ApiClass.ts, apps/meteor/server/api/v1/middlewares/permissions.ts, apps/meteor/.../api/ldap.ts, .changeset/real-mails-count.md
Route errors support additional error shapes. Permission failures return forbidden responses. LDAP handlers return unauthorized for missing authentication. The changeset documents the 401/403 distinction.
Room endpoint authorization statuses
apps/meteor/server/api/v1/rooms.ts
Room endpoints define 403 responses and return 403 for authorization failures instead of 401.
Request validation error normalization
packages/http-router/src/Router.ts, packages/http-router/src/Router.spec.ts, docs/api-endpoint-migration.md
Body validation returns error-invalid-params. Tests and migration guidance cover query and body validation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: type: bug, area: authentication

Suggested reviewers: sampaiodiego

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main API change: use 403 for authorization failures and reserve 401 for missing sessions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • API-401: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/meteor/server/api/ApiClass.ts`:
- Around line 898-904: Update the exception handling around errorKey to
normalize nullish throws before accessing properties, using the established
errorMessage value and optional access for later e.message, e.error, and e.stack
reads. Ensure null or undefined exceptions continue through the existing switch
and return the expected API response instead of causing a TypeError.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ca7a8afd-b4f5-45e1-a0dc-9c9b46233f99

📥 Commits

Reviewing files that changed from the base of the PR and between 94478c6 and c7cefd3.

📒 Files selected for processing (7)
  • .changeset/real-mails-count.md
  • apps/meteor/server/api/ApiClass.ts
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
  • docs/api-endpoint-migration.md
  • packages/http-router/src/Router.spec.ts
  • packages/http-router/src/Router.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/http-router/src/Router.ts
  • packages/http-router/src/Router.spec.ts
  • apps/meteor/server/api/ApiClass.ts
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • packages/http-router/src/Router.spec.ts
🧠 Learnings (9)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/http-router/src/Router.ts
  • packages/http-router/src/Router.spec.ts
  • apps/meteor/server/api/ApiClass.ts
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/http-router/src/Router.ts
  • packages/http-router/src/Router.spec.ts
  • apps/meteor/server/api/ApiClass.ts
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/http-router/src/Router.ts
  • packages/http-router/src/Router.spec.ts
  • apps/meteor/server/api/ApiClass.ts
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/real-mails-count.md
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
Learning: Adopt the monorepo-wide Jest testMatch pattern: <rootDir>/src/**/*.spec.{ts,js,mjs} (represented here as '**/src/**/*.spec.{ts,js,mjs}') to ensure spec files under any package's src directory are picked up consistently across all packages in the Rocket.Chat monorepo. Apply this pattern in jest.config.ts for all relevant packages to maintain uniform test discovery.

Applied to files:

  • packages/http-router/src/Router.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • packages/http-router/src/Router.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • packages/http-router/src/Router.spec.ts
📚 Learning: 2026-07-31T02:44:35.111Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 41635
File: apps/meteor/ee/server/api/sessions.ts:114-138
Timestamp: 2026-07-31T02:44:35.111Z
Learning: In Rocket.Chat typed REST response schemas, accept the composition of a Typia-generated entity schema with an `allOf` branch requiring `success: true`: `allOf: [{ $ref: <entity schema> }, { properties: { success: { type: 'boolean', enum: [true] } }, required: ['success'] }]`. Do not flag this pattern when used for REST endpoints, provided TEST_MODE response validation passes, as demonstrated by the `IOAuthApps` and `IEmailInbox` endpoints.

Applied to files:

  • apps/meteor/server/api/ApiClass.ts
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
📚 Learning: 2026-07-29T23:45:21.859Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 41632
File: apps/meteor/server/api/v1/groups.ts:948-959
Timestamp: 2026-07-29T23:45:21.859Z
Learning: For API v1 routes under apps/meteor/server/api/v1, keep item-level response schemas strict by using `$ref`-based schemas for list and messages (and ensure they intentionally mirror the corresponding route contracts, as done in channels.ts). Only use “loose”/non-`$ref` item schemas when the underlying data source is inherently partial (e.g., uploads where `content` can be `null`, or queries like `findUsersOfRoom` with a fixed projection). Do not relax item schemas merely because the route supports an optional client `fields` projection—optional field selection alone is not a reason to change schema strictness.

Applied to files:

  • apps/meteor/server/api/v1/rooms.ts
🔇 Additional comments (6)
packages/http-router/src/Router.ts (1)

248-248: LGTM!

packages/http-router/src/Router.spec.ts (1)

210-215: LGTM!

docs/api-endpoint-migration.md (1)

600-600: LGTM!

Also applies to: 618-618

apps/meteor/server/api/v1/middlewares/permissions.ts (1)

46-47: LGTM!

.changeset/real-mails-count.md (1)

1-7: LGTM!

apps/meteor/server/api/v1/rooms.ts (1)

739-739: LGTM!

Also applies to: 779-779, 815-815, 1142-1142, 1161-1161, 1301-1308, 1705-1712

Comment thread apps/meteor/server/api/ApiClass.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Re-trigger cubic

@surjeetkumar8006
surjeetkumar8006 force-pushed the fix/api-401-403-semantics-v5 branch from c7cefd3 to 85d3b43 Compare August 2, 2026 13:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/meteor/server/api/ApiClass.ts`:
- Line 899: Update the errorMessage construction near errorKey so non-string
errors fall back in order through e.message, e.reason, and a string e.error
before String(e), preserving identifiers such as error-not-authorized instead of
producing [object Object].
- Around line 903-914: Update the LDAP request handling to throw the established
missing-session error key instead of error-invalid-user when no authenticated
user exists. In ApiClass’s error-key switch, add that key to the unauthorized
branch so it returns api.unauthorized(errorMessage), while preserving the
existing forbidden mapping for error-not-authorized and other permission errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 480e8ad1-3234-4141-b3f6-645a05815e9b

📥 Commits

Reviewing files that changed from the base of the PR and between c7cefd3 and 85d3b43.

📒 Files selected for processing (7)
  • .changeset/real-mails-count.md
  • apps/meteor/server/api/ApiClass.ts
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
  • docs/api-endpoint-migration.md
  • packages/http-router/src/Router.spec.ts
  • packages/http-router/src/Router.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/http-router/src/Router.spec.ts
  • packages/http-router/src/Router.ts
  • .changeset/real-mails-count.md
  • docs/api-endpoint-migration.md
  • apps/meteor/server/api/v1/middlewares/permissions.ts
  • apps/meteor/server/api/v1/rooms.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/server/api/ApiClass.ts
🧠 Learnings (4)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/server/api/ApiClass.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/server/api/ApiClass.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/server/api/ApiClass.ts
📚 Learning: 2026-07-31T02:44:35.111Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 41635
File: apps/meteor/ee/server/api/sessions.ts:114-138
Timestamp: 2026-07-31T02:44:35.111Z
Learning: In Rocket.Chat typed REST response schemas, accept the composition of a Typia-generated entity schema with an `allOf` branch requiring `success: true`: `allOf: [{ $ref: <entity schema> }, { properties: { success: { type: 'boolean', enum: [true] } }, required: ['success'] }]`. Do not flag this pattern when used for REST endpoints, provided TEST_MODE response validation passes, as demonstrated by the `IOAuthApps` and `IEmailInbox` endpoints.

Applied to files:

  • apps/meteor/server/api/ApiClass.ts
🔇 Additional comments (1)
apps/meteor/server/api/ApiClass.ts (1)

898-898: LGTM!

Also applies to: 900-902

Comment thread apps/meteor/server/api/ApiClass.ts Outdated
Comment thread apps/meteor/server/api/ApiClass.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants